﻿@{
    ViewBag.Title = "Form"; 
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    layui.use(['jquery', 'form', 'laydate', 'tablePlug', 'common'], function () {
        var form = layui.form,
            $ = layui.$,
            common = layui.common,
            laydate = layui.laydate;
        var keyValue = $.request("keyValue");
        //权限字段
        common.authorizeFields('adminform');
        //此处需修改
        //类型为时间时
        //laydate.render({
            //elem: '#F_Birthday'
            //, btns: ['clear', 'now']
            //, trigger: 'click',
            //format: 'yyyy-MM-dd',
        //});

        $(function () {
            initControl();
            if (!!keyValue) {
                 common.ajax({
                   url: '/BasicData/Hierarchies/GetFormJson',
                   dataType: 'json',
                   data: { keyValue: keyValue },
                   async: false,
                   success: function (data) {
                       common.val('adminform', data);
                    }
               });
           }
           form.render();
       });

       function initControl() {
           //此处需修改
           //绑定数据源
           //类型为下拉框时
           $("#F_ParentCode").bindSelect({
               url: "/BasicData/Hierarchies/GetTreeSelectJson",
           });
       }

       //监听提交
        form.on('submit(saveBtn)', function (data) {
            alert(1);
            var postData = data.field;
            alert(2);
           common.submitForm({
               url: '/BasicData/Hierarchies/SubmitForm?keyValue=' + keyValue,
               param: postData,
               success: function () {
                   common.parentreload('data-search-btn');
               }
           })
           return false;
       });
   });
</script>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" lay-filter="adminform">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">级别</label>
                    <div class="layui-input-block">
                        <select id="F_Level" name="F_Level" lay-verify="required" lay-search>
                            <option value="1" selected>1</option>
                            <option value="2" selected>2</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">父类型</label>
                    <div class="layui-input-block">
                        <select id="F_ParentCode" name="F_ParentCode" lay-verify="required" lay-search>
                            <option value="0" selected>父节点</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">代码</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_Code" name="F_Code" autocomplete="off" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">名称</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_Name" name="F_Name" autocomplete="off" lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

